package ksoap2Test;

import javax.xml.soap.SOAPBody;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

public class Test {
	
	public static  void test1() throws Exception{
		String url="http://localhost:8080/wsServer01/services/JohnService?wsdl";
		HttpTransportSE trans=new HttpTransportSE(url);
		SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
		SoapObject body=new SoapObject("http://service","work");
		body.addProperty("s", "john");
		envelope.setOutputSoapObject(body);
		
		trans.call("http://service/"+"work", envelope);
		//envelope.bodyIn;
		SoapObject so=(SoapObject)envelope.bodyIn;
		for(int i=0;i<so.getPropertyCount();i++){
			System.out.println(so.getProperty(i));
		}
	}
	
	public static void main(String[] args) throws Exception{
		String url="http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl";
		String ns="http://WebXml.com.cn";
		String action="getRegionProvince";
		HttpTransportSE trans=new HttpTransportSE(url);
		SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
		SoapObject body=new SoapObject(ns, action);
		//body.addProperty("mobileCode","18868890049");
		//body.addProperty("userID","");
		envelope.setOutputSoapObject(body);
		envelope.dotNet=true;
		trans.call(ns+"/"+action, envelope);
		System.out.println(envelope.bodyIn.getClass().getName());
		System.out.println(envelope.getResponse().getClass().getName());
		SoapObject so=(SoapObject)envelope.getResponse();
		
		
		for(int i=0;i<so.getPropertyCount();i++){
			System.out.println(so.getProperty(i));
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
	}

}
